package gov.nasa.anml.lifted;

import java.util.*;

import gov.nasa.anml.utility.Pair;
import gov.nasa.anml.utility.SimpleObject;

public class Range<T extends Comparable> implements Constraint<T> {

	// optional enumeration of all possible values
	// setting this incorrectly will break Enumeration.containsAll
	// if set correctly, then Range additionally guarantees that
	// every number inside the bounds are covered, as opposed
	// to Enumeration, which does not.
	public Set<T> values; 
	public Pair<T,T> bounds;

	public Range(T lower, T upper) {
		bounds = new Pair<T,T>(lower,upper);
	}
	
	public Pair<T,T> bounds() {
		return bounds;
	}

	public boolean contains(Object o) {
		T v = (T) o; // actually casts from object to object...pretty pointless.
		if (bounds.left.compareTo(v) <= 0 &&
				bounds.right.compareTo(v) >= 0)
			return true;
		return false;
	}

	public boolean containsAll(Constraint<T> t) {
		Pair<T,T> b = t.bounds();
		if (bounds.left.compareTo(b.left) <= 0 &&
				bounds.right.compareTo(b.right) >= 0)
			return true;
		return false;
	}

	public Set<T> values() {
		return values;
	}

	public boolean add(T e) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean addAll(Collection<? extends T> c) {
		// TODO Auto-generated method stub
		return false;
	}

	public void clear() {
		// TODO Auto-generated method stub
		
	}

	public boolean containsAll(Collection<?> c) {
		for (T o : (Collection<T>) c) {
			if (bounds.left.compareTo(o) > 0)
				return false;
			if (bounds.right.compareTo(o) < 0)
				return false;
		}
		return true;
	}

	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return false;
	}

	public Iterator<T> iterator() {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean remove(Object o) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean removeAll(Collection<?> c) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean retainAll(Collection<?> c) {
		// TODO Auto-generated method stub
		return false;
	}

	public int size() {
		// TODO Auto-generated method stub
		return 0;
	}

	public Object[] toArray() {
		// TODO Auto-generated method stub
		return null;
	}

	public <T> T[] toArray(T[] a) {
		// TODO Auto-generated method stub
		return null;
	}
	
	// careful; this ought to make new memory for left and right, but it doesn't
	public Range<T> clone() {
		Range<T> r = null;
		try {
			r = (Range<T>) super.clone();
		} catch (CloneNotSupportedException e) {
			//assert false;
		}
		r.bounds = new Pair<T,T>(bounds.left,bounds.right);
		return r;
	}
}
